package com.smartleanx.module.hrm.eums.employee;

import com.smartleanx.framework.common.core.IntArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;

/**
 * 员工状态
 *
 * @author tengcj
 * @since 2024/5/17
 */
@Getter
@RequiredArgsConstructor
public enum EmployeeStatusEnum implements IntArrayValuable {

    PROBATION(1, "试用期"),

    PENDING_REGULARIZATION(2, "待转正"),

    REGULARIZED(3, "已转正"),

    // 表示非正式员工的在职状态
    INFORMAL_EMPLOYEE(4, "非正式"),

    TO_BE_SEPARATED(5, "待离职"),

    SEPARATED(6, "已离职"),
    ;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(EmployeeStatusEnum::getCode).toArray();

    private final Integer code;

    private final String desc;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    /**
     * 根据code返回desc
     *
     * @param code 编号
     * @return 名称
     */
    public static String getName(Integer code) {
        for (EmployeeStatusEnum e : EmployeeStatusEnum.values()) {
            if (e.getCode().equals(code)) {
                return e.getDesc();
            }
        }
        return null;
    }
}
